import java.util.Scanner;

/**
 * @author zhaoqian
 * @create 2021/8/31 9:38
 */
public class test777 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            int sum=0;
            int p = in.nextInt();
            for (int i=7;i<=p;i++){
                if (i%7==0){
                    sum++;
                    continue;
                }
                int t=i;
                while (t!=0) {
                    if (t % 10 == 7) {
                        sum++;
                        break;
                    }
                    t = t / 10;
                }
            }
            System.out.println(sum);

        }
    }
}
